package com.frame.database;

import java.lang.reflect.ParameterizedType;

import com.frame.database.proxy.JServiceProxy;

import net.sf.cglib.proxy.Enhancer;

public class JServiceFactory {

        public static <T> T createJServiceProxy(Class<T> c){
                ParameterizedType pt = (ParameterizedType)c.getGenericSuperclass();
                Class daoClass=(Class)pt.getActualTypeArguments()[0];
                JServiceProxy proxy=new JServiceProxy();
                proxy.setDaoClass(daoClass);
                return (T)Enhancer.create(c, proxy);
//		try {
//			return (T)c.newInstance();
//		} catch (InstantiationException | IllegalAccessException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		return null;
        }
}
